package cn.wangqi.personal.dao;

import org.mybatis.spring.SqlSessionTemplate;
import cn.wangqi.personal.domain.BlogTag;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import cn.wangqi.personal.util.Page;
import org.apache.log4j.Logger;
import java.util.Map;
import javax.annotation.Resource;


/**
 *created by admin  2017-10-17 02:42:51
 */
@Repository
public class BlogTagDao{
    private final String NAMESPACE = this.getClass().getName() + ".";
    private Logger logger = Logger.getLogger(BlogTagDao.class);
    @Resource
    protected SqlSessionTemplate mainSqlSession;
    public void saveBlogTag(BlogTag blogTag) {
        mainSqlSession.insert(NAMESPACE + "saveBlogTag", blogTag);
    }

    public void saveBlogTag(List<BlogTag> blogTag) {
        mainSqlSession.insert(NAMESPACE + "saveBlogTagList", blogTag);
    }

    public void deleteBlogTagById(int blogTagId) {
        mainSqlSession.delete(NAMESPACE + "deleteBlogTagById", blogTagId);
    }

    public BlogTag findBlogTagById(int blogTagId){
        return mainSqlSession.selectOne(NAMESPACE + "findBlogTagById", blogTagId);
    }

    public List<BlogTag> listBlogTag(int blogTagId, Page page){
        Map<String, Object> params = new HashMap<>();
        params.put("page",page);
        return mainSqlSession.selectList(NAMESPACE + "listBlogTag", params);
    }

    public int countBlogTag(){
        Map<String, Object> params = new HashMap<>();
        return mainSqlSession.selectOne(NAMESPACE + "totalBlogTag",params);
    }

    public void updateBlogTag(BlogTag blogTag){
        mainSqlSession.update(NAMESPACE + "updateBlogTag", blogTag);
    }

}
